package com.Vronsky.core.factory;

import com.Vronsky.core.dataSource.SimpleDataSource;

import java.sql.SQLException;

//通过工厂来保证数据源对象单例，可要是人们创建多个工厂就不能保证数据源对象单例了，待完善
//
public class SimpleDataSourceFactory {
    //单例
    private static SimpleDataSource simpleDataSource;

    static {
        try {
            simpleDataSource = SimpleDataSource.getSimpleDataSource();
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }


    private SimpleDataSourceFactory() throws SQLException, ClassNotFoundException {
    }


    //
    public static SimpleDataSource getSimpleDataSource() {
        return simpleDataSource;
    }
}
